package com.hyl.springbootappinfo.web.converter;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class StringToDateConverter implements Converter<String, Date> {

    private String dataPattern;

    public StringToDateConverter(String dataPattern) {
        this.dataPattern = dataPattern;
    }

    @Override
    public Date convert(String s) {
        Date date=null;
        try {
            date=new SimpleDateFormat().parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
}
